package com.database;

import com.server.util.PackageScan;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

public class HibernateUtils {
    public static void ExportDB(List<String> list) {
        AnnotationConfiguration configuration = new AnnotationConfiguration().configure();
        for (String classPackage : list) {
            Set<Class<?>> classes = PackageScan.getClasses(classPackage);
            configuration.addPackage(classPackage);
            for (Class<?> aClass : classes) {
                configuration.addAnnotatedClass(aClass);
            }
        }
        SchemaExport export = new SchemaExport(configuration);
        export.execute(true, true, false, false);
    }

    public static void main(String[] args) {
        List<String> list = new ArrayList<String>();
        list.add("com.ace_server.model");
        list.add("com.permission.model");
        HibernateUtils.ExportDB(list);
    }
}
